package com.health.pay.tencent.business;

import com.alibaba.fastjson.JSONArray;
import com.health.pay.tencent.common.Util;
import com.health.pay.tencent.common.XMLParser;
import com.health.pay.tencent.protocol.transfers.TransfersReq;
import com.health.pay.tencent.protocol.transfers.TransfersResp;
import com.health.pay.tencent.service.TransfersService;

public class TransfersBusiness {

	private TransfersService transfersService;

	public TransfersBusiness() throws IllegalAccessException,
			ClassNotFoundException, InstantiationException {
		transfersService = new TransfersService();
	}

	public TransfersResp run(TransfersReq transfersReq) throws Exception {


		String refundServiceResponseString;

		String objXmlString = XMLParser.map2XmlString(transfersReq.toMap());
		refundServiceResponseString = transfersService.request(objXmlString);
		TransfersResp transfersResp = (TransfersResp) Util.getObjectFromXML(
				refundServiceResponseString, TransfersResp.class);
		
		System.out.println(JSONArray.toJSONString(transfersResp));

		return transfersResp;

	}

}
